const _room = require("./room");
const _roomGroup = require("./roomGroup");
const { Sequelize, DataTypes } = require("sequelize");
const sequelize = new Sequelize("yzczb", "root", "mysql_cswynw", {
  host: "120.27.240.51",
  port: 33306,
  dialect: "mysql",
  define: {
    timestamps: false,
  },
});
// 下面这两个是模型文件
const Room = _room(sequelize);
const RoomGroup = _roomGroup(sequelize);

RoomGroup.hasMany(Room, {
  foreignKey: "groupId",
  targetId: "id",
  as: "rg",
});
Room.belongsTo(RoomGroup, {
  foreignKey: "groupId",
  targetId: "id",
  as: "rg",
});

module.exports = {
  Room,
  RoomGroup,
};
